package com.gopay.remote.cps.expresspay;

import com.gopay.common.constants.ep.EpBindState;
import com.gopay.common.constants.ep.EpCardType;
import com.gopay.common.domain.ep.EpCardBin;
import com.gopay.common.domain.ep.EpCardBindInfo;
import com.gopay.common.domain.ep.EpCardBindInfoVo;
import com.gopay.common.domain.ep.EpCardStatus;

import java.util.Date;
import java.util.List;

/**
 * 快捷支付银行卡远程服务接口
 * 
 * EpBankCardRemoteService.java
 * @author zhangjunyu
 * @2014-8-29 下午1:21:39 www.gopay.com.cn Inc.All rights reserved.
 */
public interface EpBankCardRemoteService {

    /**
     * 判断cardNo是否与bankCode匹配
     * 
     * @param cardNo
     *            银行卡号
     * @param bankCode
     *            银行码short_name
     * @return 匹配与否
     */
    public Boolean isCardBelongBank(String cardNo, String bankCode);
    
    /**
     * 通过卡号、银行码匹配查找EpCardBin对象，并返回卡bin对象
     * @param cardNo
     * @param bankCode
     * @return
     */
    public EpCardBin findCardBinByMatchingCardInfo(String cardNo, String bankCode);

    /**
     * 快捷支付银行绑定
     */
    public void bindBankCard(EpCardBindInfo bindInfo);
    public EpCardBindInfo bindEpCardInfo(EpCardBindInfo bindInfo);
    /**
     * 根据ID解绑快捷支付银行卡
     */
    public void unBindBankCardByIdAndCustId(Integer id, String custId);
    
    /**
     * 根据手机号、银行码查询对象
     * @param mobile    手机号
     * @param bankCode  银行码
     * @param cardType  卡类型
     * @return
     */
    public EpCardBindInfo getByMobileBankCodeCardType(String mobile, String bankCode, EpCardType cardType);
    
    /**
     * 判断是否为快捷用户
     * @param mobile
     * @return
     */
    public Boolean isEpMobile(String mobile);

    /**
     * 根据银行代码和用户ID获取绑定关系
     * @param bankCode
     * @param custId
     * @return
     */
    public EpCardBindInfo getCardInfoByCustIdBankCode(String bankCode, String custId,EpCardType cardType);
    /**
     * 通过卡号匹配查找EpCardBin对象并返回
     */
    public EpCardBin findCardBinByMatchingCardNo(String cardNo);
    /**
     * 根据用户ID和银行卡号获取绑定关系
     * @param custId
     * @param cardType
     * @return
     */
    public EpCardBindInfo getCardInfoByCustIdBankNo(String custId, String bankAcctNum, EpCardType cardType);

    public void updateEpCardBindInfo(EpCardBindInfo cardInfo);

    List<EpCardBindInfo> getCardInfoByCustId(String custId, EpCardType cardType);

    /**
     * 按照绑定日期和绑定状态清除绑定信息，防止表垃圾数据增长
     * @param bindDateBefore 绑定时间（本方法将清理该时间之前的特定状态的绑定关系）
     * @param state 绑定状态
     * @return
     */
    public Boolean cleanBindInfoByBindTimeAndStatus(Date bindDateBefore, EpBindState state);
    public EpCardBindInfo getTEMPCardInfoByCustIdBankNo(String custId, String bankAcctNum, EpCardType cardType);

    /**
     * 快捷支付二期
     * @param cardNo
     * @return
     */
    public EpCardBin getEpCardBinByCardNo(String cardNo);


    public List<EpCardBindInfo> getBindCardInfoByCustId(String custId);

    /**
     * 获得绑定的银行卡
     * @param custId
     * @param bankAcctNum
     * @return
     */
    public EpCardBindInfo getBindCardInfoByCustIdBankNo(String custId, String bankAcctNum);

    /**
     * 获得绑定的银行卡
     * @param bankAcctNum
     * @return
     */
    public EpCardBindInfo getBindCardInfoByBankNo(String bankAcctNum);

    /**
     * 获得绑定和临时的银行卡
     * @param custId
     * @param bankAcctNum
     * @return
     */
    public EpCardBindInfo getBindAntTempCardInfoByCustIdAndBankNo(String custId, String bankAcctNum);

    /**
     * 获得未绑定的银行卡
     * @param custId
     * @param bankAcctNum
     * @return
     */
    public EpCardBindInfo getUnBindCardInfoByCustIdBankNo(String custId, String bankAcctNum);

    public EpCardBindInfo getTEMPCardInfoByCustIdBankNo(String custId, String bankAcctNum);

	public EpCardStatus errAccum4CertNo(String cardNo);

	public boolean isFreezeCardNo(String cardNo);

	public EpCardStatus errAccum4SMS(String cardNo);

	public EpCardStatus errAccum4Pay(String cardNo);

    public EpCardBindInfo getCardInfoById(String cardId);

	public Boolean clearBankCardStatus();

	public List<EpCardBindInfoVo> getBindCardInfoVoByCustId(String custId);

	public void clrErrNum4CertNo(String cardNo);

	public EpCardBindInfo getById(Integer id);
    /**
     * 通过卡号前六位匹配查找EpCardBin对象并返回
     */
    public EpCardBin findCardBinByMatchingCardNoFront(String cardNo);
	
}
